<template>
    <div class="home-content">
        <header>
            <span class="btn-box">
                <span v-if="props.showHome" class="iconfont icon-shouye" @click="goHome"></span>
            </span>
            <span class="btn-box">
                <span class="iconfont icon-fanhui" v-if="props.showBack" @click="goBack"></span>

            </span>
            <span class="text">{{ props.title }}</span>
            <span class="btn-box right">
                <span class="iconfont icon-tianjia1" v-if="props.showNew" @click="newEvt"></span>
            </span>
        </header>
        <main>

            <slot />
        </main>
        <footer>
            <van-tabbar active-color="#ffd591" inactive-color="#fff7e6" route>
                <van-tabbar-item icon="home-o" to="/home">首页</van-tabbar-item>
                <van-tabbar-item icon="orders-o" to="/purchase/list">采购管理</van-tabbar-item>
                <van-tabbar-item icon="friends-o" to="/project/list">项目管理</van-tabbar-item>
                <van-tabbar-item icon="user-o" to="/my">我的</van-tabbar-item>
            </van-tabbar>
        </footer>
    </div>
    <!-- v-model="active" -->

</template>
<script setup>
import { ref, onMounted, defineProps } from "vue";
import { useRouter,useRoute } from "vue-router";


let _router = useRouter()
let route=useRoute()
let props = defineProps({
    showHome: {
        type: Boolean,
        default: false
    },
    showNew: {
        type: Boolean,
        default: false
    },
    showBack: {
        type: Boolean,
        default: false
    }
    ,
    title: {
        type: String,
        required: true
    }
})
// const active = ref(1);

function goHome() {
    _router.push('/home')
}
function goBack() {
    _router.back()
}
function newEvt() {

    if (route.path == '/purchase/list') {
        _router.push('/purchase/edit')
    }else{
        _router.push('/project/edit')
    }
}

</script>
<style lang="less" scoped>
@import url('../../style/common.less');

.home-content {
    display: block;
    position: relative;
    height: 100%;
    width: 100%;
    z-index: 10;

    >header {
        text-align: center;
        height: 48px;
        line-height: 48px;
        font-size: 0.9rem;
        font-weight: bold;
        background: @b04;
        color: @b00;

        >.btn-box {
            position: relative;
            height: 100%;
            float: left;
            z-index: 11;

            >.home,
            .iconfont {
                display: inline-block;
                font-size: 26px;
                margin-right: 10px;
                margin-left: 10px;
            }

            &.right {
                float: right;
            }
        }

        >.text {
            display: block;
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 48px;
        }
    }

    >main {
        position: relative;
        // padding-top: 5px;
        height: calc(100% - 48px - 46px);
        overflow-x: hidden;
    }

    >footer {
        position: relative;
        height: 46px;

    }
}
</style>